package com.ruoyi.web.controller.production.plug;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.plug.PlugType;
import com.ruoyi.production.service.plug.IPlugTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 穴盘类型Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/plugType")
public class PlugTypeController extends BaseController
{
    @Autowired
    private IPlugTypeService plugTypeService;

    /**
     * 查询穴盘类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlugType plugType)
    {
        startPage();
        List<PlugType> list = plugTypeService.selectPlugTypeList(plugType);
        return getDataTable(list);
    }

    /**
     * 导出穴盘类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:export')")
    @Log(title = "穴盘类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PlugType plugType)
    {
        List<PlugType> list = plugTypeService.selectPlugTypeList(plugType);
        ExcelUtil<PlugType> util = new ExcelUtil<PlugType>(PlugType.class);
        return util.exportExcel(list, "穴盘类型数据");
    }

    /**
     * 获取穴盘类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:query')")
    @GetMapping(value = "/{plugTypeId}")
    public AjaxResult getInfo(@PathVariable("plugTypeId") Long plugTypeId)
    {
        return AjaxResult.success(plugTypeService.selectPlugTypeById(plugTypeId));
    }

    /**
     * 新增穴盘类型
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:add')")
    @Log(title = "穴盘类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlugType plugType)
    {
        return toAjax(plugTypeService.insertPlugType(plugType));
    }

    /**
     * 修改穴盘类型
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:edit')")
    @Log(title = "穴盘类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlugType plugType)
    {
        return toAjax(plugTypeService.updatePlugType(plugType));
    }

    /**
     * 删除穴盘类型
     */
    @PreAuthorize("@ss.hasPermi('production:plugType:remove')")
    @Log(title = "穴盘类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{plugTypeIds}")
    public AjaxResult remove(@PathVariable Long[] plugTypeIds)
    {
        return toAjax(plugTypeService.deletePlugTypeByIds(plugTypeIds));
    }
}
